#ifndef MAGICBRUSHTOOL_H
#define MAGICBRUSHTOOL_H

#include "globalstates.h"
#include "rendermanager.h"
#include "Drawing.h"
#include "vector3.h"
#include "tool.h"
#include <iostream>
#include <queue>
#include <sstream>

using namespace std;

class MagicBrushTool : virtual public Tool
{
public:
    enum ACTION{NEW=1, ADD=2, SUBTRACT=3};
    enum FIX_COLOUR {RED = 1, GREEN = 2, BLUE = 4};
private:
    enum VARIABLE{COLOR = 1};
    enum KEY_SHORTCUTS {KEY_RESET = Qt::Key_R};
    enum MODIFIERS { KEY_ADD = Qt::ShiftModifier,
                     KEY_SUBTRACT = Qt::AltModifier};
    MagicBrushTool();
    GlobalStates* global;
    vector3<int> coords;
    char varToCheck;
    float redTolerance;
    float blueTolerance;
    float greenTolerance;
    bool isContiguous;
    ACTION action;

public:

    //get and set methods
    static MagicBrushTool* getInstance();
    string getType();
    Result setColourTolerance(FIX_COLOUR c, float tol);
    float getColourTolerance(FIX_COLOUR c);
    void toggleContiguous(bool b);
    Result setAction(ACTION a);
    int getAction();

    void toggleVariable(VARIABLE var);
    bool isVariableSet(VARIABLE var);
    bool checkContiguity();

    //backend
    bool checkVoxelProperties(vector3<int> v, colour c, bool inSelection, set<vector3<int> >& permitted);
    Result execute();

    //events
    Result mousePressEvent(QMouseEvent *event);
    Result keyPressEvent(QKeyEvent *event);

    friend class MagicBrushATD;
};

#endif // MAGICBRUSHTOOL_H
